#include<string>
#include<stack>
#include<iostream>
using namespace std;

class Solution {
public:
    int calculate(string s) {
        stack<int> nums;
        char ys = '+';
        int i = 0;

        while (i < s.size()) {
            // cout<<nums.top()<<endl;
            bool isrunning = false;
            int tmp = 0;
            while (s[i] >= '0' && s[i] <= '9') {
                tmp *= 10;
                tmp += s[i] - '0';
                i++;
                isrunning = true;
            }
            // cout<<"tmp"<<tmp<<endl;
            if (isrunning) {
                if (ys == '+') {
                    nums.push(tmp);
                }
                else if (ys == '-') {
                    nums.push(tmp * -1);
                    // cout<<nums.top()<<endl;
                }
                else if (ys == '*') {
                    nums.top() *= tmp;
                }
                else if (ys == '/') {
                    nums.top() /= tmp;
                    // cout<<nums.top()<<endl;
                }
                cout << nums.top() << endl;
            }
            if (s[i] == '+' || s[i] == '-' || s[i] == '*' || s[i] == '/') {
                ys = s[i];
                cout << ys << endl;
            }
            i++;
        }
        int ret = 0;
        while (!nums.empty()) {
            ret += nums.top();
            nums.pop();
        }
        return ret;
    }
};